<#include "/layout/layout.ftl">
<#import "/layout/macro.ftl" as macro>
<#assign css>
<style>
</style>
</#assign>
<#assign js>
<script>
	function changeStat(id,stat) {
	    var msg = "停用";
	    if("0"==stat) msg = "启用";
		layer.confirm('确定'+msg+'吗?', {icon: 3, title: '提示'}, function (index) {
			$.ajax({
				type: "POST",
				dataType: "json",
				data:{"status":stat},
				url: "/agentService/changeStat/" + id,
				success: function (res) {
					layer.msg(res.message, {time: 2000}, function () {
						location.reload();
					});
				}
			});
		});
	}

	//tableId,queryId,conditionContainer
	//var userTable;
	var winId="userWin";
	$(function() {
		//init table and fill data
		//userTable = new CommonTable("user_table", "user_list", "searchDiv");

		//button event
		$('button[data-btn-type]').click(function() {
			var action = $(this).attr('data-btn-type');
			var rowId="ceshi";
			switch (action) {
				case 'add':
					modals.openWin({
						winId:winId,
						title:'新增agentservice',
						width:'900px',
						url:"/agentService/edit/ceshi"
					});
					break;
				case 'edit':
					if(!rowId){
						modals.info('请选择要编辑的行');
						return false;
					}
					modals.openWin({
						winId:winId,
						title:'编辑agentservice【'+userTable.getSelectedRowData().name+'】',
						width:'900px',
						url:"/agentService/edit/"+rowId,
					});
					break;
				case 'delete':
					if(!rowId){
						modals.info('请选择要删除的行');
						return false;
					}
					modals.confirm("是否要删除该行数据？",function(){
						ajaxPost(basePath+"/agentService/delete/"+rowId,null,function(data){
							if(data.success){
								//modals.correct("已删除该数据");
								userTable.reloadRowData();
							}else{
								modals.error("agentservice数据被引用，不可删除！");
							}
						});
					})
					break;
			}

		});
		//form_init();
	});
</script>
</#assign>
<@layout title="上门服务二级分类管理" active="oneclass">
<!-- Content Header (Page header) -->
<section class="content-header">
	<h1>
		服务业务设置-${serviceClassName}
	</h1>
	<ol class="breadcrumb">
		<li><a href="/index"><i class="fa fa-home"></i> 管理后台</a></li>
		<li><a href="/service/oneclass/index"><i class="fa fa-list-ul"></i> 服务业务设置</a></li>
		<li class="active"><i class="fa fa-table"></i> ${serviceClassName}</li>
	</ol>
</section>

<!-- Main content -->
<section class="content">
	<!-- Default box -->
	<div class="box box-primary">
		<div class="box-header">
        <@shiro.hasPermission name="service:oneclass:add">
			<a class="btn btn-sm btn-success" href="/agentService/add/${serviceClass}">新增</a>
        </@shiro.hasPermission>
		</div>
		<div class="box-body">
			<table class="table table-striped">
				<tr>
					<th></th>
                    <th>一级分类</th>
					<th>二级名称</th>
					<th>定价方式</th>
					<th>定价/上门费</th>
					<th>状态</th>
					<th>创建日期</th>
					<th>创建人</th>
					<th>操作</th>
				</tr>
                <#list pageInfo.list as item>
                <tr>
					<td >${item.serviceCode!}</td>
					<td >${convert('SERVICE_CLASS',item.serviceClass) !}</td>
					<td  >${item.serviceName!}</td>
					<td  >${convert('PRICE_TYPE',item.priceWay)!}</td>
					<td >${item.fee?string.number!}</td>
                    <td >
						<#if item.deleteStatus==0>
							<span class="label label-info">正常</span>
						<#elseif item.deleteStatus==1>
                            <span class="label label-danger">已停用</span>
						</#if>

					</td>
					<td >${item.createAt?string('yyyy-MM-dd HH:mm:ss')}</td>
					<td >${item.createBy!}</td>
					<td>
                    <@shiro.hasPermission name="service:oneclass:edit">
                        <a class="btn btn-sm btn-primary" href="/agentService/edit/${item.id}" data-btn-type="edit">编辑</a>
                    </@shiro.hasPermission>
                    <@shiro.hasPermission name="service:oneclass:delete">
						<#if item.deleteStatus==0>
							<button class="btn btn-sm btn-danger" onclick="changeStat('${item.id}','1')">停用</button>
						<#elseif item.deleteStatus==1>
                            <button class="btn btn-sm btn-info" onclick="changeStat('${item.id}','0')">启用</button>
						</#if>
                    </@shiro.hasPermission>
					</td>
				</tr>
                </#list>
			</table>
		</div>
		<!-- /.box-body -->
		<div class="box-footer clearfix">
            <@macro.page pageInfo=pageInfo url="/agentService/index?" />
		</div>
	</div>
	<!-- /.box -->

</section>
<!-- /.content -->
</@layout>
